// pages/receipt/receipt.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navH: 0,
    order: [],
    i: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      navH: app.globalData.navHeight
    })
    var that = this
    wx.request({
      url: 'http://localhost:8081/getorder/' + app.data.userInfo[0].userId,
      success(res) {
        that.setData({
          order: res.data
        })
      }
    })
  },

  goBack: function () {
    wx.navigateBack({
      delta: 1
    })
  },

  confirm: function(event) {
    wx.request({
      url: 'http://localhost:8081/deleteorder/' + app.data.userInfo[0].userId + '/' + this.data.order[event.currentTarget.id].productName,
    })
    wx.showToast({
      title: '已签收',
      icon: 'success',
      duration: 2000
    })
    var b = this.data.order
    b.splice(event.currentTarget.id, 1)
    this.setData({
      order: b
    })

  }
})